package com.example.module.iot.aws.callback;

import lombok.extern.slf4j.Slf4j;
import software.amazon.awssdk.crt.CRT;
import software.amazon.awssdk.crt.mqtt.MqttClientConnectionEvents;

@Slf4j
public class AwsMqttConnectionCallback implements MqttClientConnectionEvents {
    @Override
    public void onConnectionInterrupted(int errorCode) {
        if (errorCode != 0) {
            log.warn("Connection interrupted: {}: {}", errorCode, CRT.awsErrorString(errorCode));
        }
    }

    @Override
    public void onConnectionResumed(boolean sessionPresent) {
        log.info("Connection resumed: {}", sessionPresent ? "existing session" : "clean session");
    }
}
